using System.ComponentModel.DataAnnotations.Schema;
using System.Data.Entity.ModelConfiguration;

namespace ConsoleApplication2.Models.Mapping
{
    public class SO_CONTRACTDETMap : EntityTypeConfiguration<SO_CONTRACTDET>
    {
        public SO_CONTRACTDETMap()
        {
            // Primary Key
            this.HasKey(t => new { t.id, t.Contract, t.coverage_plan, t.coverage_class, t.price_list_name, t.VISIT_CEILING });

            // Properties
            this.Property(t => t.id)
                .HasDatabaseGeneratedOption(DatabaseGeneratedOption.None);

            this.Property(t => t.Contract)
                .IsRequired()
                .HasMaxLength(50);

            this.Property(t => t.coverage_plan)
                .IsRequired()
                .HasMaxLength(50);

            this.Property(t => t.coverage_class)
                .IsRequired()
                .HasMaxLength(50);

            this.Property(t => t.price_list_name)
                .IsRequired()
                .HasMaxLength(50);

            this.Property(t => t.CONTRACT_ID)
                .HasMaxLength(12);

            this.Property(t => t.VISIT_CEILING)
                .HasDatabaseGeneratedOption(DatabaseGeneratedOption.None);

            // Table & Column Mappings
            this.ToTable("SO_CONTRACTDET");
            this.Property(t => t.id).HasColumnName("id");
            this.Property(t => t.Contract).HasColumnName("Contract");
            this.Property(t => t.coverage_plan).HasColumnName("coverage_plan");
            this.Property(t => t.coverage_class).HasColumnName("coverage_class");
            this.Property(t => t.price_list_name).HasColumnName("price_list_name");
            this.Property(t => t.CONTRACT_ID).HasColumnName("CONTRACT_ID");
            this.Property(t => t.VISIT_CEILING).HasColumnName("VISIT_CEILING");
        }
    }
}
